<?php
include_once "../header1.php";
?>
<script type="text/javascript">
function getHttpRequest()
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
function showHint(str)
{
var xmlhttp;    
if (str=="")
  {
  document.getElementById("List").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("List").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","upp_res_names.php?q="+str,true);
xmlhttp.send();
}
function fill(val)
{
document.DelRes.ResName.value=val;
document.getElementById("List").innerHTML="";
var xmlhttp;    
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
   document.getElementById("SNO").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","resnames.php?q="+val,true);
xmlhttp.send();
}
</script>
<script type="text/javascript">
function DeleteVerification()
{
   
  <?php
include_once ("../Login/databaseconnection.php");

if(!loggedin())
{
	require_once ("../index.php");
}
   
   else
   {
   ?>
	var Resource_Id=document.forms["DelRes"]["ResName"].value;
var Serial_Number=document.forms["DelRes"]["Serial_Number"].value;
  if(Resource_Id==""||Serial_Number=="Select One")
	   {
		   alert("Please select the Resource name and Serial number!");
   return false;
	   } 
  if(Resource_Id!=""&&Serial_Number!="Select One")
	   {
	   var r=confirm("Are you sure to delete this?");
if (r==true)
  {
     return true;

 }

if(r==false)
  {
 return false;
  }
}
}
</script>
</head>
<body>
 <?php
require_once '../Login/databaseconnection.php';
if(!loggedin())
{
require_once '../index.php';
}
  else
   {
   ?>
   <?php
include_once "../header2.php";
?>
<?php
include_once "topmenu.php";
?> 
<div id="content">
	<div id="main">
	  <div id="bodyfield">
<div id="lefttable">
<form  name="DelRes" action="#" method="POST" onSubmit="return DeleteVerification()">
<?php
if(isset($_POST['Delete']))
{
require_once 'DEL.php';
}
?>
  <table width="543" border="0" class="tablefontv">
    <tr>
      <td height="18" colspan="5" scope="row" class="err">
      <?php
      if(isset($_POST['Delete']))
{
	if(isset($_SESSION['errorin']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errorin'];
		unset($_SESSION['errorin']);
	}
	if(isset($_SESSION['error']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['error'];
		unset($_SESSION['error']);
	}
	if(isset($_SESSION['errornorow']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
	if(isset($_SESSION['errornot2']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornot2'];
		unset($_SESSION['errornot2']);
	}
	if(isset($_SESSION['errornot']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornot'];
		unset($_SESSION['errornot']);
	}
	if(isset($_SESSION['errornotallo']))
	{
	echo '<img src="../images/alert.jpg" width="12" height="12"/>';
		echo $_SESSION['errornotallo'];
		unset($_SESSION['errornotallo']);
	}
}   
?>
</td>
      </tr>
    <tr>
      <th width="67" rowspan="3"  scope="row" bgcolor="#6AB5FF">&nbsp;</th>
      <td width="138" height="29"  scope="row" bgcolor="#6AB5FF">Resource's Type:</td>
      <td colspan="2" bgcolor="#999999">
       <?php
	  $get_r_name=mysql_query("SELECT * FROM resource WHERE Resource_Id='$Resource_Id'");
	if($r_name=mysql_fetch_array($get_r_name))
	{
	 $Res_Name=$r_name['Resource_Type'];
	 }
	 	  echo "<input type='text' id='ResName' name='ResName' onKeyUp='showHint(this.value)' value='$Res_Name' onClick='cleartbox()' size='25'/>";
	  ?></td>
      <td width="156" rowspan="2" bgcolor="#6AB5FF">&nbsp;</td>
    </tr>
    <tr>
      <td height="30" scope="row" bgcolor="#6AB5FF">Serial Number:</td>
      <td colspan="2" bgcolor="#999999"><div id="SNO"><select name="Serial_Number" id="Serial_Number">
        <?php
	  
	  if(isset($_POST['Delete']))
	  {
	echo '<option value="'.$Serial_Number.'">'.$Serial_Number.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
		 $Resource_Id=$_POST['Resource_Id'];
	   if($Resource_Id!="Select One")
	  {
	  $res=mysql_query("SELECT DISTINCT(Serial_Number) FROM resource_details WHERE Resource_Id='$Resource_Id'");
	  }
	  if($Resource_Id=="Select One"||$Resource_Id=="")
	  {
	  $res=mysql_query("SELECT DISTINCT(Serial_Number) FROM resource_details");
	  }
  while($row=mysql_fetch_array($res))
  {
	  $Ser_Number=$row['Serial_Number'];
	   if($Ser_Number!=$Serial_Number)
{
	 echo '<option value="'.$Ser_Number.'">'.$Ser_Number.'</option>';
}
	 
  }
	  ?>
      </select></div></td>
      </tr>
    <tr>
      <th height="30" colspan="4" scope="row" bgcolor="#6AB5FF"><a href="DelRes.php" class="reset">Reset |</a>
        <input name="Delete" align="middle" type="submit" value="Delete" class="buttonok"/></th>
      </tr>
    
  </table>

  <br/>
  <br/>
   </form>
  <?php
   	   if(isset($_POST['Delete']))
{
if($_SESSION['Access_Type']=="Administrator"||$_SESSION['Access_Type']=="Teacher in Charge")
{
  if($Serial_Number!=""&&$Lab_Id!=""&&$Resource_Type!="")
   {
	   echo '<table width="458" border="0" class="tablefontv">';
	    ?>
    <?php
       
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Serial Number:";
		echo '</th>';
        echo '<td>';
		echo $Serial_Number;
		echo '</td>';
      echo '</tr>';
	   echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Resource Type:";
		echo '</th>';
        echo '<td>';
		echo $Resource_Type;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Functioning:";
		echo '</th>';
       echo '<td>';
	   echo $Functioning;
	   echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Brand Name:"; 
		echo '</th>';
        echo '<td>';
		echo $Brand_Name;
            
        echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Date Of Supplied:"; 
		echo '</th>';
        echo '<td>';
		echo $Date_Of_Supplied;
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th width="200" height="44" scope="row">';
		echo "Name Of Supplier:";
		echo '</th>';
        echo '<td width="144">';
		echo $Name_Of_Supplier;
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "Funding Source:";
		echo '</th>';
        echo '<td>';
		echo $Funding_Source;
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="44" scope="row">';
		echo "School Id:";
		echo '</th>';
        echo '<td>';
		echo $School_Id;
		echo '</td>';
      echo '</tr>';
	    echo '</table>';
	
	}
	}
	}
	}
    ?>
	</div>
  <div id="righttablereg">
  <div class="suggestionListsch" id="List"></div></div>
</div>
</div>
</div>
</div>
</div>
<div id="sidebar">
<br/>
<div id="partners" class="boxed">
			<h2 class="title">RESOURCES</h2>
            </div>
<?php
include_once "menu.php";
?>
 <?php
include_once "../footer.php";
?>
<?php
}
?>
</body>
</html>